#include <epoxy/gl.h>
typedef struct {
+ GdkDisplay *display;
GdkWindow *window;
GdkGLContext *shared_context;
GdkGLProfile profile;
enum {
PROP_0,
+ PROP_DISPLAY,
PROP_WINDOW,
PROP_PROFILE,
PROP_SHARED_CONTEXT,
if (current == context)
g_private_replace (&thread_current_context, NULL);
+ g_clear_object (&priv->display);
g_clear_object (&priv->window);
g_clear_object (&priv->shared_context);
switch (prop_id)
{
+ case PROP_DISPLAY:
+ {
+ GdkDisplay *display = g_value_get_object (value);
+
+ if (display)
+ g_object_ref (display);
+
+ if (priv->display)
+ g_object_unref (priv->display);
+
+ priv->display = display;
+ }
+ break;
+
case PROP_WINDOW:
{
GdkWindow *window = g_value_get_object (value);
switch (prop_id)
{
+ case PROP_DISPLAY:
+ g_value_set_object (value, priv->display);
+ break;
+
case PROP_WINDOW:
g_value_set_object (value, priv->window);
break;
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ /**
+ * GdkGLContext:display:
+ *
+ * The #GdkWindow the gl context is bound to.
+ *
+ * Since: 3.16
+ */
+ obj_pspecs[PROP_DISPLAY] =
+ g_param_spec_object ("display",
+ P_("Display"),
+ P_("The GDK display the context is from"),
+ GDK_TYPE_DISPLAY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
/**
* GdkGLContext:window:
*
if (current == context)
return;
- if (gdk_display_make_gl_context_current (gdk_window_get_display (priv->window), context))
+ if (gdk_display_make_gl_context_current (priv->display, context))
{
g_private_replace (&thread_current_context, g_object_ref (context));
if (!priv->realized)
}
}
+/**
+ * gdk_gl_context_get_display:
+ * @context: a #GdkGLContext
+ *
+ * Retrieves the #GdkDisplay the @context is created for
+ *
+ * Returns: (transfer none): a #GdkDisplay or %NULL
+ *
+ * Since: 3.16
+ */
+GdkDisplay *
+gdk_gl_context_get_display (GdkGLContext *context)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
+
+ return priv->display;
+}
+
/**
* gdk_gl_context_get_window:
* @context: a #GdkGLContext
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (current);
- if (gdk_display_make_gl_context_current (gdk_window_get_display (priv->window), NULL))
+ if (gdk_display_make_gl_context_current (priv->display, NULL))
g_private_replace (&thread_current_context, NULL);
}
}
{
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
GdkWindow *window = gdk_gl_context_get_window (context);
- GdkDisplay *display = gdk_window_get_display (window);
+ GdkDisplay *display = gdk_gl_context_get_display (context);
Display *dpy = gdk_x11_display_get_xdisplay (display);
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
DrawableInfo *info;
if (context_x11->glx_context != NULL)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
- GdkWindow *window = gdk_gl_context_get_window (context);
- GdkDisplay *display = gdk_window_get_display (window);
+ GdkDisplay *display = gdk_gl_context_get_display (context);
Display *dpy = gdk_x11_display_get_xdisplay (display);
if (glXGetCurrentContext () == context_x11->glx_context)
is_direct ? "direct" : "indirect"));
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
+ "display", display,
"window", window,
"profile", profile,
"shared-context", share,